set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
# 由cflags指定std=c99， 如果由这里的CMAKE_C_STANDARD指定，会引入gnu99， 这会放到flags最后，
# 从而导致系统不会使用_ISOC99_SOURCE的宏, 从而会导致系统采用的是GNU的source。
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_BUILD_TYPE "Debug")


set(FNO_BUILTIN_FLAGS "-fno-builtin-printf -fno-builtin-time -fno-builtin-gmtime -fno-builtin-gettimeofday -fno-builtin-mktime -fno-builtin-puts")
set(ROOT_DIR "D:/projects/quectel/ql_v12_8x8/ql-cross-tool/win32/owtoolchain/gcc-arm-none-eabi")
get_filename_component(ROOT_DIR_FULL "${ROOT_DIR}" ABSOLUTE)                     

set(CMAKE_FIND_ROOT_PATH "${ROOT_DIR_FULL}/arm-none-eabi" "${ROOT_DIR_FULL}/lib/gcc/arm-none-eabi/9.2.1")
set(CMAKE_SYSROOT "${ROOT_DIR_FULL}/arm-none-eabi")
set(CMAKE_AR "${ROOT_DIR_FULL}/bin/arm-none-eabi-ar.exe")
set(CMAKE_ASM_COMPILER "${ROOT_DIR_FULL}/bin/arm-none-eabi-as.exe")
set(CMAKE_C_COMPILER "${ROOT_DIR_FULL}/bin/arm-none-eabi-gcc.exe")
set(CMAKE_CXX_COMPILER "${ROOT_DIR_FULL}/bin/arm-none-eabi-g++.exe")
set(CMAKE_STATIC_LIBRARY_SUFFIX_C .lib)
set(STDLINK_LIB "${ROOT_DIR_FULL}/arm-none-eabi/lib/thumb/v7/nofp/libc.a 
${ROOT_DIR_FULL}/arm-none-eabi/lib/thumb/v7/nofp/libstdc++.a 
${ROOT_DIR_FULL}/lib/gcc/arm-none-eabi/9.2.1/libgcc.a 
${ROOT_DIR_FULL}/arm-none-eabi/lib/thumb/v7/nofp/libg.a
${ROOT_DIR_FULL}/arm-none-eabi/lib/thumb/v7/nofp/libnosys.a
${ROOT_DIR_FULL}/arm-none-eabi/lib/thumb/v7/nofp/libm.a")

option(USING_EXTERNAL_OPUS "using external opus lib" ON)

set(CMAKE_C_FLAGS_INIT "-MMD -mlong-calls -mcpu=cortex-r4 -mfloat-abi=soft -mlittle-endian -mthumb -mthumb-interwork -Wall -ffunction-sections -fdata-sections ${FNO_BUILTIN_FLAGS} -D__OCPU_COMPILER_GCC__ -D_WANT_USE_LONG_TIME_T -std=c99 -Os")
set(CMAKE_CXX_FLAGS_INIT "-MMD -mlong-calls -mcpu=cortex-r4 -mfloat-abi=soft -mlittle-endian -mthumb -mthumb-interwork -Wall -ffunction-sections -fdata-sections ${FNO_BUILTIN_FLAGS} -D__OCPU_COMPILER_GCC__ -D_WANT_USE_LONG_TIME_T -std=c++11 -Os")
set(CMAKE_ASM_FLAGS_INIT "-mlong-calls -mcpu=cortex-r4 -mfloat-abi=soft -mlittle-endian -mthumb -mthumb-interwork -Wall -Os")

set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

